/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NeuralInternalFrame.java
 *
 * Created on Feb 2, 2010, 9:58:04 AM
 */
package org.neuralstudio;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import org.jane.utils.SupervisedDataset;
import org.jane.core.TransferFunctions;
import org.jane.core.functions.LogSigmoidFunction;
import org.jane.core.functions.TanhFunction;
import org.jane.core.layers.SimpleLayer;
import org.jane.core.networks.AbstractNeuralNetwork;
import org.jane.core.networks.AbstractSupervisedNeuralNetwork;
import org.jane.core.networks.Adaline;
import org.jane.core.networks.CompetitiveNetwork;
import org.jane.core.networks.KohonenSelfOrganizingMap;
import org.jane.core.networks.MultiLayerPerceptron;
import org.jane.core.networks.Perceptron;
import org.jane.core.trainers.BackpropagationTrainer;
import org.jane.core.trainers.DeltaRuleTrainer;
import org.jane.core.trainers.DifferentialEvolutionTrainer;
import org.jane.core.trainers.INetTrainer;
import org.jane.core.trainers.PerceptronTrainer;
import org.jane.utils.AbstractDataset;
import org.jane.utils.UnsupervisedDataset;
import org.jane.utils.VectorUtils;
import org.lobobrowser.html.UserAgentContext;
import org.lobobrowser.html.gui.HtmlPanel;
import org.lobobrowser.html.parser.DocumentBuilderImpl;
import org.lobobrowser.html.parser.InputSourceImpl;
import org.lobobrowser.html.test.SimpleHtmlRendererContext;
import org.lobobrowser.html.test.SimpleUserAgentContext;
import org.math.plot.Plot2DPanel;
import org.math.plot.Plot3DPanel;
import org.math.plot.PlotPanel;
import org.neuralstudio.utils.AproximationTrainerThread;
import org.neuralstudio.utils.ClassificationTrainerThread;
import org.neuralstudio.utils.GraphSceneImpl;
import org.neuralstudio.utils.NeuralFileFilter;
import org.neuralstudio.utils.Utils;

/**
 *
 * @author william
 */
public class NeuralInternalFrame extends javax.swing.JInternalFrame {

    private AbstractSupervisedNeuralNetwork supervisedNetwork;
    private CompetitiveNetwork unsupervisedNetwork;
    private List<List<List<Float>>> resultData;
    private PlotPanel plotPanel;
    private List<Color> colors;


    /** Creates new form NeuralInternalFrame */
    public NeuralInternalFrame() {
        initComponents();
        //this.jPanel5.setSize(WIDTH, WIDTH);
        jTabbedPane1.setEnabledAt(1,false);
        jTabbedPane1.setEnabledAt(2,false);
        jTabbedPane1.setEnabledAt(3,false);
        this.jPanel5.setLayout(new GridBagLayout());
        this.jPanel14.setLayout(new GridBagLayout());
        this.jPanel18.setLayout(new GridBagLayout());
        this.addComponents(false,null);
        this.jComboBox2.setModel(TrainingDataManager.getInstance().getComboModel(true));
        this.jComboBox2.setModel(TrainingDataManager.getInstance().getComboModel(true));
        this.colors = new ArrayList<Color>();
        //HtmlPanel panel = new HtmlPanel();
        //panel.setSize(jPanel19.getWidth(), jPanel18.getHeight());
        //panel.setPreferredWidth(jPanel19.getWidth());
        //jPanel19.add(panel,BorderLayout.CENTER);
        //new InputSourceImpl();
        //this.showDescription(0);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        perceptronPanel = new javax.swing.JPanel();
        jSpinner1 = new javax.swing.JSpinner();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jSpinner6 = new javax.swing.JSpinner();
        jLabel15 = new javax.swing.JLabel();
        mlpPanel = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jSpinner2 = new javax.swing.JSpinner();
        jLabel7 = new javax.swing.JLabel();
        jSpinner3 = new javax.swing.JSpinner();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel5 = new javax.swing.JPanel();
        jLabel21 = new javax.swing.JLabel();
        jComboBox5 = new javax.swing.JComboBox();
        competitivePanel = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jSpinner4 = new javax.swing.JSpinner();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jSpinner5 = new javax.swing.JSpinner();
        jLabel17 = new javax.swing.JLabel();
        jSpinner8 = new javax.swing.JSpinner();
        jPanel6 = new javax.swing.JPanel();
        jComboBox1 = new javax.swing.JComboBox();
        createNetButton = new javax.swing.JButton();
        jScrollPane7 = new javax.swing.JScrollPane();
        jPanel2 = new javax.swing.JPanel();
        graphPanel = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jRadioButton2 = new javax.swing.JRadioButton();
        jTextField2 = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        trainButton = new javax.swing.JButton();
        jSpinner7 = new javax.swing.JSpinner();
        jLabel20 = new javax.swing.JLabel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jLabel16 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jProgressBar1 = new javax.swing.JProgressBar();
        jPanel9 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        jPanel18 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        errorPlotPanel = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        infoTextArea = new javax.swing.JTextArea();
        jPanel3 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        classificationTrainButton = new javax.swing.JButton();
        jSpinner9 = new javax.swing.JSpinner();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jSpinner10 = new javax.swing.JSpinner();
        jLabel26 = new javax.swing.JLabel();
        jComboBox3 = new javax.swing.JComboBox();
        jButton3 = new javax.swing.JButton();
        jProgressBar2 = new javax.swing.JProgressBar();
        graphPanel1 = new javax.swing.JPanel();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jButton5 = new javax.swing.JButton();
        jPanel13 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jPanel14 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        graphPanel2 = new javax.swing.JPanel();
        jPanel15 = new javax.swing.JPanel();
        jRadioButton3 = new javax.swing.JRadioButton();
        jTextField4 = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        trainButton1 = new javax.swing.JButton();
        jSpinner11 = new javax.swing.JSpinner();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jSpinner12 = new javax.swing.JSpinner();
        jRadioButton4 = new javax.swing.JRadioButton();
        jLabel29 = new javax.swing.JLabel();
        jComboBox4 = new javax.swing.JComboBox();
        jButton6 = new javax.swing.JButton();
        jProgressBar3 = new javax.swing.JProgressBar();
        jPanel16 = new javax.swing.JPanel();
        jTextField6 = new javax.swing.JTextField();
        jLabel30 = new javax.swing.JLabel();
        jButton7 = new javax.swing.JButton();
        jPanel17 = new javax.swing.JPanel();
        errorPlotPanel1 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        infoTextArea1 = new javax.swing.JTextArea();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();

        setClosable(true);
        setIconifiable(true);
        setTitle("Neural Studio");
        setEnabled(false);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Parámetros"));
        jPanel4.setLayout(new java.awt.CardLayout());

        jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));
        jSpinner1.setEditor(new javax.swing.JSpinner.NumberEditor(jSpinner1, ""));

        jLabel1.setText("Número de neuronas");

        jLabel2.setText("Número de capas");

        jLabel3.setText("1");

        jLabel4.setText("Tipo de función de transferencia");

        jLabel5.setText("Hardlimit");

        jSpinner6.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0010f), Float.valueOf(0.0010f), null, Float.valueOf(0.0050f)));

        jLabel15.setText("Tasa de aprendizaje");

        javax.swing.GroupLayout perceptronPanelLayout = new javax.swing.GroupLayout(perceptronPanel);
        perceptronPanel.setLayout(perceptronPanelLayout);
        perceptronPanelLayout.setHorizontalGroup(
            perceptronPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(perceptronPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(perceptronPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(perceptronPanelLayout.createSequentialGroup()
                        .addGroup(perceptronPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
                        .addGroup(perceptronPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel5)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, perceptronPanelLayout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 71, Short.MAX_VALUE)
                        .addComponent(jSpinner6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, perceptronPanelLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 100, Short.MAX_VALUE)
                        .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(139, 139, 139))
        );
        perceptronPanelLayout.setVerticalGroup(
            perceptronPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(perceptronPanelLayout.createSequentialGroup()
                .addGap(57, 57, 57)
                .addGroup(perceptronPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(perceptronPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jSpinner6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(perceptronPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(perceptronPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5))
                .addContainerGap(100, Short.MAX_VALUE))
        );

        jPanel4.add(perceptronPanel, "card2");

        mlpPanel.setPreferredSize(new java.awt.Dimension(500, 291));

        jLabel6.setText("Número de capas");

        jSpinner2.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));
        jSpinner2.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSpinner2StateChanged(evt);
            }
        });

        jLabel7.setText("Tipo de capa y número de neuronas por capa");

        jSpinner3.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0010f), Float.valueOf(0.0010f), null, Float.valueOf(0.0050f)));

        jLabel8.setText("Tasa de aprendizaje");

        jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));
        jPanel5.setLayout(null);
        jScrollPane1.setViewportView(jPanel5);

        jLabel21.setText("Entrenador");

        jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Backprop", "Differential Evolution" }));

        javax.swing.GroupLayout mlpPanelLayout = new javax.swing.GroupLayout(mlpPanel);
        mlpPanel.setLayout(mlpPanelLayout);
        mlpPanelLayout.setHorizontalGroup(
            mlpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mlpPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mlpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mlpPanelLayout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(183, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mlpPanelLayout.createSequentialGroup()
                        .addGroup(mlpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mlpPanelLayout.createSequentialGroup()
                                .addComponent(jLabel21)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
                                .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mlpPanelLayout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 82, Short.MAX_VALUE)
                                .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mlpPanelLayout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
                                .addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(511, 511, 511))))
        );
        mlpPanelLayout.setVerticalGroup(
            mlpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mlpPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mlpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(mlpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mlpPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel4.add(mlpPanel, "card3");

        jLabel9.setText("Número de neuronas");

        jSpinner4.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));

        jLabel10.setText("Número de capas");

        jLabel11.setText("2");

        jLabel12.setText("Función de transferencia");

        jLabel13.setText("Lineal/ Lineal Positiva");

        jLabel14.setText("Tasa de aprendizaje");

        jSpinner5.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0010f), Float.valueOf(0.0010f), null, Float.valueOf(0.0050f)));

        jLabel17.setText("Tamaño del vecindario");

        jSpinner8.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));

        javax.swing.GroupLayout competitivePanelLayout = new javax.swing.GroupLayout(competitivePanel);
        competitivePanel.setLayout(competitivePanelLayout);
        competitivePanelLayout.setHorizontalGroup(
            competitivePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, competitivePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(competitivePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(competitivePanelLayout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 199, Short.MAX_VALUE)
                        .addComponent(jSpinner8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(competitivePanelLayout.createSequentialGroup()
                        .addGroup(competitivePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jLabel14)
                            .addComponent(jLabel10)
                            .addComponent(jLabel12))
                        .addGap(115, 115, 115)
                        .addGroup(competitivePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(competitivePanelLayout.createSequentialGroup()
                                .addGap(40, 40, 40)
                                .addGroup(competitivePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jSpinner4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jSpinner5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(competitivePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
                                .addGroup(competitivePanelLayout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel11))))))
                .addGap(121, 121, 121))
        );
        competitivePanelLayout.setVerticalGroup(
            competitivePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(competitivePanelLayout.createSequentialGroup()
                .addGap(53, 53, 53)
                .addGroup(competitivePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(competitivePanelLayout.createSequentialGroup()
                        .addComponent(jSpinner4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jSpinner5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel11)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel13))
                    .addGroup(competitivePanelLayout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel14)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel10)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel12)))
                .addGap(18, 18, 18)
                .addGroup(competitivePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jSpinner8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17))
                .addContainerGap(52, Short.MAX_VALUE))
        );

        jPanel4.add(competitivePanel, "card4");

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Tipo de red neuronal"));

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Seleccione una...", "Perceptrón", "Adaline", "Perceptrón Multicapa", "Red Competitiva", "SOM" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(172, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        createNetButton.setText("Crear Red");
        createNetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                createNetButtonActionPerformed(evt);
            }
        });

        jScrollPane7.setBorder(javax.swing.BorderFactory.createTitledBorder("Representación gráfica de la red"));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(createNetButton, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                        .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 629, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 373, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(40, 40, 40)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(createNetButton)))
                .addContainerGap(93, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Configuración de la red", jPanel1);

        graphPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Respuesta de la red (Rojo - función original, Azul - respuesta de la red)"));
        graphPanel.setLayout(new java.awt.BorderLayout());

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Parámetros de entrenamiento"));

        buttonGroup1.add(jRadioButton2);
        jRadioButton2.setSelected(true);
        jRadioButton2.setText("Usar función");
        jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton2ActionPerformed(evt);
            }
        });

        jLabel18.setText("Función");

        jLabel19.setText("Intérvalo (min,max)");

        trainButton.setText("Entrenar");
        trainButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                trainButtonActionPerformed(evt);
            }
        });

        jSpinner7.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1000), null, Integer.valueOf(100000), Integer.valueOf(1)));

        jLabel20.setText("Max. Iteraciones");

        buttonGroup1.add(jRadioButton1);
        jRadioButton1.setText("Usar dataset estándar");
        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton1ActionPerformed(evt);
            }
        });

        jLabel16.setText("Seleccione uno");

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox2.setEnabled(false);
        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/neuralstudio/1265600870_arrow_circle_double.png"))); // NOI18N
        jButton1.setEnabled(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel18))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel19)
                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jRadioButton2))
                .addGap(32, 32, 32)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                                .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE))
                            .addComponent(jProgressBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel20)
                            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(trainButton)
                                .addComponent(jSpinner7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(625, 625, 625))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addContainerGap(253, Short.MAX_VALUE))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jRadioButton1)
                        .addContainerGap())))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jRadioButton1)
                            .addComponent(jRadioButton2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel18)
                            .addComponent(jLabel19))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jLabel20)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSpinner7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(trainButton)))
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("Entradas"));

        jButton2.setText("Procesar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jScrollPane6.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 315, Short.MAX_VALUE)
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jScrollPane6.setViewportView(jPanel18);

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton2))
        );

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder("Info Red y Error"));

        errorPlotPanel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        errorPlotPanel.setLayout(new java.awt.BorderLayout());

        infoTextArea.setColumns(20);
        infoTextArea.setRows(5);
        jScrollPane2.setViewportView(infoTextArea);

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(errorPlotPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE)
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(errorPlotPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel8, 0, 621, Short.MAX_VALUE)
                    .addComponent(graphPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 621, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 50, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(17, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(graphPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Aproximación de funciones", jPanel2);

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder("Parámetros de entrenamiento"));

        classificationTrainButton.setText("Entrenar");
        classificationTrainButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                classificationTrainButtonActionPerformed(evt);
            }
        });

        jSpinner9.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1000), null, Integer.valueOf(100000), Integer.valueOf(1)));

        jLabel24.setText("Max. Iteraciones");

        jLabel25.setText("Min Error");

        jSpinner10.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.1f), Float.valueOf(0.0010f), null, Float.valueOf(0.0050f)));

        jLabel26.setText("Seleccione dataset");

        jComboBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox3ActionPerformed(evt);
            }
        });

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/neuralstudio/1265600870_arrow_circle_double.png"))); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jSpinner9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel24))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jSpinner10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel25))
                                .addGap(39, 39, 39))
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addComponent(jProgressBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addComponent(classificationTrainButton))
                    .addComponent(jLabel26))
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addComponent(jLabel26)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel24)
                                    .addComponent(jLabel25))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jSpinner9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jSpinner10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                        .addComponent(jProgressBar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(classificationTrainButton, javax.swing.GroupLayout.Alignment.TRAILING)))
        );

        graphPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Conjunto de datos"));
        graphPanel1.setLayout(new java.awt.BorderLayout());

        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultados"));

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setRows(5);
        jScrollPane4.setViewportView(jTextArea1);

        jButton5.setText("Limpiar");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE)
                    .addComponent(jButton5))
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jButton5)
                .addContainerGap())
        );

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder("Entradas"));

        jButton4.setText("Procesar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 446, Short.MAX_VALUE)
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jScrollPane3.setViewportView(jPanel14);

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE)
                    .addComponent(jButton4))
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(graphPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(40, 40, 40)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(graphPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE))
                .addGap(96, 96, 96))
        );

        jTabbedPane1.addTab("Clasificación de datos", jPanel3);

        graphPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Respuesta de la red"));
        graphPanel2.setLayout(new java.awt.BorderLayout());

        jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder("Parámetros de entrenamiento"));

        buttonGroup1.add(jRadioButton3);
        jRadioButton3.setText("Usar función");
        jRadioButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton3ActionPerformed(evt);
            }
        });

        jLabel22.setText("Función");

        jLabel23.setText("Intérvalo (min,max)");

        trainButton1.setText("Entrenar");
        trainButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                trainButton1ActionPerformed(evt);
            }
        });

        jSpinner11.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1000), null, Integer.valueOf(100000), Integer.valueOf(1)));

        jLabel27.setText("Max. Iteraciones");

        jLabel28.setText("Tamaño ventana");

        jSpinner12.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));

        buttonGroup1.add(jRadioButton4);
        jRadioButton4.setText("Usar dataset estándar");
        jRadioButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton4ActionPerformed(evt);
            }
        });

        jLabel29.setText("Seleccione uno");

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox4.setEnabled(false);

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/neuralstudio/1265600870_arrow_circle_double.png"))); // NOI18N
        jButton6.setEnabled(false);
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel22))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel23)
                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jRadioButton3))
                .addGap(32, 32, 32)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel15Layout.createSequentialGroup()
                                .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jSpinner11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel27))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel28)
                                    .addComponent(jSpinner12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel15Layout.createSequentialGroup()
                                .addComponent(jProgressBar3, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(trainButton1)))
                        .addGap(556, 556, 556))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jLabel29)
                        .addContainerGap(404, Short.MAX_VALUE))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jRadioButton4)
                        .addContainerGap())))
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jRadioButton4)
                            .addComponent(jRadioButton3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel29)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel22)
                            .addComponent(jLabel23))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel27)
                            .addComponent(jLabel28))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jSpinner11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jSpinner12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jProgressBar3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(trainButton1)))
        );

        jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder("Entradas"));

        jLabel30.setText("Entradas (separadas por coma)");

        jButton7.setText("Procesar");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton7)
                    .addComponent(jLabel30)
                    .addComponent(jTextField6, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel16Layout.createSequentialGroup()
                .addContainerGap(41, Short.MAX_VALUE)
                .addComponent(jLabel30)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23)
                .addComponent(jButton7))
        );

        jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder("Info"));

        errorPlotPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        errorPlotPanel1.setLayout(new java.awt.BorderLayout());

        infoTextArea1.setColumns(20);
        infoTextArea1.setRows(5);
        jScrollPane5.setViewportView(infoTextArea1);

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(errorPlotPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE)
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(errorPlotPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                        .addComponent(graphPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 600, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, 772, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(76, 76, 76))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(graphPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Predicción de series de tiempo", jPanel7);

        jMenu1.setText("Opciones");

        jMenuItem1.setText("Abrir...");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Guardar...");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1052, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 581, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(70, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // TODO add your handling code here:
        String selectedNetwork = this.jComboBox1.getSelectedItem().toString();
        if ("Perceptrón".equals(selectedNetwork)) {
            this.jLabel5.setText("Hard Limit");
            this.jSpinner6.setVisible(false);
            CardLayout cl = (CardLayout) jPanel4.getLayout();
            cl.show(this.jPanel4, "card2");
        }
        if ("Adaline".equals(selectedNetwork)) {
            this.jLabel5.setText("Lineal");
            CardLayout cl = (CardLayout) jPanel4.getLayout();
            this.jSpinner6.setVisible(true);
            cl.show(this.jPanel4, "card2");
        }
        if ("Perceptrón Multicapa".equals(selectedNetwork)) {
            CardLayout cl = (CardLayout) jPanel4.getLayout();
            cl.show(this.jPanel4, "card3");
        }
        if ("Red Competitiva".equals(selectedNetwork)) {
            CardLayout cl = (CardLayout) jPanel4.getLayout();
            cl.show(this.jPanel4, "card4");
            jSpinner8.setEnabled(false);
            jLabel17.setEnabled(false);
        }
        if ("SOM".equals(selectedNetwork)) {
            CardLayout cl = (CardLayout) jPanel4.getLayout();
            cl.show(this.jPanel4, "card4");
            jSpinner8.setEnabled(true);
            jLabel17.setEnabled(true);
        }
        //showDescription(jComboBox1.getSelectedIndex());
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void showDescription(int netType) {
        //jPanel19.removeAll();
        HtmlPanel panel = new HtmlPanel();
        try{
           // new SimpleHtmlRendererContext(panel, new SimpleUserAgentContext()).navigate("http://lobobrowser.org/browser/home.jsp");

            // This panel should be added to a JFrame or
            // another Swing component.
            UserAgentContext ucontext = new SimpleUserAgentContext();
            SimpleHtmlRendererContext rcontext = new SimpleHtmlRendererContext(panel, ucontext);
            // Note that document builder should receive both contexts.
            DocumentBuilderImpl dbi = new DocumentBuilderImpl(ucontext, rcontext);
            URL myurl = null;
            switch (netType) {
                case 1:
                    myurl = this.getClass().getResource("/org/neuralstudio/resources/html/perceptron.html");
                    break;
                case 2:
                    myurl = this.getClass().getResource("/org/neuralstudio/resources/html/adaline.html");
                    break;
                case 3:
                    myurl = this.getClass().getResource("/org/neuralstudio/resources/html/mperceptron.html");
                    break;
                case 4:
                    myurl = this.getClass().getResource("/org/neuralstudio/resources/html/competitiveNetwork.html");
                    break;
                case 0:
                    myurl = this.getClass().getResource("/org/neuralstudio/resources/html/index.html");
            }

            // A documentURI should be provided to resolve relative URIs.
            InputStreamReader reader = new InputStreamReader(myurl.openConnection().getInputStream());
            org.w3c.dom.Document document = dbi.parse(new InputSourceImpl(reader, myurl.toString()));
            // Now set document in panel. This is what causes the document to render.
            panel.setDocument(document, rcontext);

        } catch (Exception ex) {
            ex.toString();
        }

        //jPanel19.add(panel,BorderLayout.CENTER);
    }
    private void addComponents(boolean guided, Integer[] data) {
        Integer v = 1;

        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridy = this.jPanel5.getComponentCount() / 2;
        c.gridx = 0;
        JComboBox comboCapas = new JComboBox();
        comboCapas.setModel(new DefaultComboBoxModel(new String[]{"Sigmoide", "Lineal", "Tangente hiperbólica"}));
        JSpinner spinner = new JSpinner();
        if (guided) {
            comboCapas.setSelectedIndex(data[0]);
            v = data[1];
        }
        spinner.setModel(new javax.swing.SpinnerNumberModel(v, Integer.valueOf(1), Integer.valueOf(100), Integer.valueOf(1)));
        //spinner.setSize(500, 30);

        c.fill = GridBagConstraints.HORIZONTAL;
        this.jPanel5.add(comboCapas, c);
        c.gridx = 1;
        //c.anchor = GridBagConstraints.NORTHWEST;
        this.jPanel5.add(spinner, c);
    }
    private void jSpinner2StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner2StateChanged
        // TODO add your handling code here:
        Integer value = (Integer) jSpinner2.getValue();
        if (value > this.jPanel5.getComponentCount() / 2) {
            this.addComponents(false, null);
        }
        if (value < this.jPanel5.getComponentCount() / 2) {
            this.jPanel5.remove(this.jPanel5.getComponentCount() - 1);
            this.jPanel5.remove(this.jPanel5.getComponentCount() - 1);
        }
        this.jPanel5.revalidate();
        this.jPanel5.repaint();
    }//GEN-LAST:event_jSpinner2StateChanged

    private void createNetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createNetButtonActionPerformed
        // TODO add your handling code here:
        int resp = JOptionPane.OK_OPTION;
        if (this.supervisedNetwork != null || this.unsupervisedNetwork != null) {
            resp = JOptionPane.showConfirmDialog(this, "Perderá la info sin guardar, desea continuar?", "Confirmar", JOptionPane.OK_CANCEL_OPTION);
        }
        if (resp == JOptionPane.OK_OPTION) {
            createNet(false);
        }
        
        
    }//GEN-LAST:event_createNetButtonActionPerformed

    private void createNet(boolean fromXml) {
        jProgressBar1.setValue(0);
        jProgressBar2.setValue(0);
        int[] networkData = null;
        String selectedNetwork = this.jComboBox1.getSelectedItem().toString();
         this.setTitle("NeuralStudio-"+selectedNetwork);
        if ("Perceptrón".equals(selectedNetwork)) {
            //new Perceptron(new PerceptronTrainer(),1);
            if (!fromXml) {
                this.supervisedNetwork = new Perceptron(new PerceptronTrainer(), (Integer) jSpinner1.getValue());
                this.unsupervisedNetwork = null;
            }
            jComboBox3.setEnabled(true);
            jComboBox3.setModel(TrainingDataManager.getInstance().getComboModel(true));
            if (this.jComboBox3.getModel().getSize() > 0)
                this.jComboBox3.setSelectedIndex(0);
            jTabbedPane1.setEnabledAt(1,false);
            jTabbedPane1.setEnabledAt(2,true);
           networkData = new int[1];
            networkData[0] = (Integer)jSpinner1.getValue();

        }
        if ("Adaline".equals(selectedNetwork)) {
            if (!fromXml) {
                this.supervisedNetwork = new Adaline(new DeltaRuleTrainer(), (Integer) jSpinner1.getValue());
                this.supervisedNetwork.setLearningRate((Float) jSpinner6.getValue());
                this.unsupervisedNetwork = null;
            }
            jComboBox3.setEnabled(true);
            jComboBox3.setModel(TrainingDataManager.getInstance().getComboModel(true));
            if (this.jComboBox3.getModel().getSize() > 0)
                this.jComboBox3.setSelectedIndex(0);
            jTabbedPane1.setEnabledAt(1,false);
            jTabbedPane1.setEnabledAt(2,true);
            networkData = new int[1];
            networkData[0] = (Integer)jSpinner1.getValue();

        }
        if ("Perceptrón Multicapa".equals(selectedNetwork)) {
            Object[][] neuronData = new Object[(Integer) this.jSpinner2.getValue()][2];
            networkData = new int[(Integer) this.jSpinner2.getValue()];
            //networkData[0] = (Integer)jSpinner1.getValue();
            int j = 0;
            for (int i = 0; i < neuronData.length; i++) {
                neuronData[i][0] = (Integer) ((JSpinner) this.jPanel5.getComponent(j+1)).getValue();
                networkData[i] = (Integer) ((JSpinner) this.jPanel5.getComponent(j+1)).getValue();
                String functionType = ((JComboBox) this.jPanel5.getComponent(j)).getSelectedItem().toString();
                if ("Sigmoide".equals(functionType)) {
                    neuronData[i][1] = TransferFunctions.LOGSIGMOID;
                }
                if ("Lineal".equals(functionType)) {
                    neuronData[i][1] = TransferFunctions.PURELIN;
                }
                 if ("Tangente hiperbólica".equals(functionType)) {
                    neuronData[i][1] = TransferFunctions.TANH;
                }
                j = j+2;


            }

            /*int[] graphData = new int[neuronData.length];
            for (int i = 0; i < neuronData.length; i++) {
                graphData[i] = (Integer)neuronData[i][0];
            }
            */
            String t = this.jComboBox5.getSelectedItem().toString();
            INetTrainer trainer = null;
            if ("Backprop".equals(t)) {
                trainer = new BackpropagationTrainer();
            }else{
                trainer = new DifferentialEvolutionTrainer();
            }
            if (!fromXml) {
                this.supervisedNetwork = new MultiLayerPerceptron(trainer, neuronData, (Float) this.jSpinner3.getValue());
                this.unsupervisedNetwork = null;
            }
            jTabbedPane1.setEnabledAt(1,true);
            jTabbedPane1.setEnabledAt(2,true);
            //jComboBox2.setEnabled(true);
            jComboBox3.setEnabled(true);
            this.addSpinners(1, jPanel18);
            jComboBox2.setModel(TrainingDataManager.getInstance().getComboModel(true));
            if (this.jRadioButton1.isSelected() && this.jComboBox2.getModel().getSize() > 0)
                this.jComboBox2.setSelectedIndex(0);
            jComboBox3.setModel(TrainingDataManager.getInstance().getComboModel(true));
            if (this.jComboBox3.getModel().getSize() > 0)
                this.jComboBox3.setSelectedIndex(0);
            //jComboBox4.setModel(TrainingDataManager.getInstance().getComboModel(true));
            //this.addSpinners((Integer)neuronData[0][0]);
            //this.addSpinners(1, jPanel18);
            //this.jRadioButton2.setSelected(true);
        }
        if ("Red Competitiva".equals(selectedNetwork)) {
            if (!fromXml) {
                this.unsupervisedNetwork = new CompetitiveNetwork((Integer) jSpinner4.getValue(), (Float) jSpinner5.getValue());
                this.supervisedNetwork = null;
            }
            this.jTextArea1.setText("");
            jComboBox3.setEnabled(true);
            jComboBox3.setModel(TrainingDataManager.getInstance().getComboModel(false));
            if (this.jComboBox3.getModel().getSize() > 0)
                this.jComboBox3.setSelectedIndex(0);
            this.colors = new ArrayList();
            jTabbedPane1.setEnabledAt(1,false);
            jTabbedPane1.setEnabledAt(2,true);
            networkData = new int[2];
            networkData[0] = (Integer) jSpinner4.getValue();
            networkData[1] = (Integer) jSpinner4.getValue();
        }
        if ("SOM".equals(selectedNetwork)) {
            if (!fromXml) {
                this.unsupervisedNetwork = new KohonenSelfOrganizingMap((Integer) jSpinner4.getValue(), (Float) jSpinner5.getValue(),(Integer)jSpinner8.getValue());
                this.supervisedNetwork = null;
            }
            this.jTextArea1.setText("");
            jComboBox3.setEnabled(true);
            jComboBox3.setModel(TrainingDataManager.getInstance().getComboModel(false));
            if (this.jComboBox3.getModel().getSize() > 0)
                this.jComboBox3.setSelectedIndex(0);
            this.colors = new ArrayList();
            jTabbedPane1.setEnabledAt(1,false);
            jTabbedPane1.setEnabledAt(2,true);
            networkData = new int[2];
            networkData[0] = (Integer) jSpinner4.getValue();
            networkData[1] = (Integer) jSpinner4.getValue();
        }
        this.graphPanel1.removeAll();
        this.graphPanel.removeAll();
        this.errorPlotPanel.removeAll();
        /*
        mxGraph graph = new mxGraph();
        Object parent = graph.getDefaultParent();
        graph.getModel().beginUpdate();
        try
            {
                if (this.supervisedNetwork != null) {
                   for(int i = 0; i < networkData.length; i++) {
                       for(int j = 0; j < networkData[i]; j++) {
                           graph.insertVertex(parent, null, "Neurona", (i+1)*100, (j+1)*100, 40, 30);
                       }
                   }
                }
                //Object v1 = graph.insertVertex(parent, null, "Hello", 20, 20, 80, 30);
                //Object v2 = graph.insertVertex(parent, null, "World!", 240, 150, 80, 30);
                //graph.insertEdge(parent, null, "Edge", v1, v2);
            }
            finally
            {
                    graph.getModel().endUpdate();
            }
        mxGraphComponent graphComponent = new mxGraphComponent(graph);
        graphComponent.setMaximumSize(new Dimension(jPanel18.getWidth(),jPanel18.getHeight()));
        jPanel18.removeAll();
        jPanel18.add(graphComponent);
        */
        this.plotNetwork(networkData, Color.decode("0x9999FF"));
    }

    private void plotNetwork(int[] networkData, Color color) {
        GraphSceneImpl scene = new GraphSceneImpl();
        for (int i = 0; i < networkData.length; i++) {
            scene.paintLayer(networkData[i], color);
        }
        scene.connectLayers(networkData);
        jScrollPane7.setViewportView(scene.createView());

    }
    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed
        // TODO add your handling code here:
        jComboBox2.setEnabled(true);
        jButton1.setEnabled(true);
        jTextField2.setEnabled(false);
        jTextField3.setEnabled(false);
        if (this.jComboBox2.getModel().getSize() > 0)
            this.jComboBox2.setSelectedIndex(0);
    }//GEN-LAST:event_jRadioButton1ActionPerformed

    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed
        // TODO add your handling code here:
        this.addSpinners(1, jPanel18);
        jComboBox2.setEnabled(false);
        jButton1.setEnabled(false);
        jTextField2.setEnabled(true);
        jTextField3.setEnabled(true);
    }//GEN-LAST:event_jRadioButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        this.jComboBox2.setModel(TrainingDataManager.getInstance().getComboModel(true));
        if (this.jComboBox2.getModel().getSize() > 0)
            this.jComboBox2.setSelectedIndex(0);
}//GEN-LAST:event_jButton1ActionPerformed

    private void trainButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trainButtonActionPerformed
        // TODO add your handling code here:
        //this.trainButton.setEnabled(false);
        //if (this.supervisedNetwork != null)

        try {

        this.graphPanel.removeAll();
        this.errorPlotPanel.removeAll();
        Plot2DPanel errorPlot = new Plot2DPanel();
        this.errorPlotPanel.add(errorPlot,BorderLayout.CENTER);
        List<List<List<Float>>> dataset = new ArrayList<List<List<Float>>>();
        List<double[]> arrays = null;
        double[] x = null;
        double[] y = null;
        if (this.supervisedNetwork != null) {
            if (jTextField2.isEnabled()) {
                dataset = Utils.getDatasetFromFunction(jTextField2.getText(),
                        Utils.getValuesInRange(Float.parseFloat(jTextField3.getText().split(",")[0]),Float.parseFloat((jTextField3.getText().split(","))[1]),0.05f));
                /*x = Utils.getDoubleValuesInRange(Float.parseFloat(jTextField3.getText().split(",")[0]),Float.parseFloat((jTextField3.getText().split(","))[1]),0.05f);
                y = Utils.getValuesFromFunction(jTextField2.getText(),x,0.05f);*/
                arrays = Utils.getArraysFromDataset(dataset);
            }else{
                dataset = ((SupervisedDataset)TrainingDataManager.getInstance().getDataset(jComboBox2.getSelectedItem().toString())).getData();
                arrays = Utils.getArraysFromDataset(dataset);
            }
            if (dataset.get(0).get(0).size() == 1){
                double[][] d = new double[arrays.get(0).length][2];
                for(int i = 0 ; i < arrays.get(0).length; i++) {
                    d[i][0] = arrays.get(0)[i];
                    d[i][1] = arrays.get(1)[i];
                }
                this.plotPanel = new Plot2DPanel();
                ((Plot2DPanel)plotPanel).addLinePlot("Funcion original",Color.red, d);
                this.graphPanel.add(this.plotPanel,BorderLayout.CENTER);
            }else{
                if (dataset.get(0).get(0).size() == 2) {
                    /*
                    this.plotPanel = new Plot3DPanel();
                    this.graphPanel.add(this.plotPanel,BorderLayout.CENTER);
                     for (int j = 0; j < arrays.get(0).length; j++) {
                        for (int k = 0; k < arrays.get(1).length; k++) {
                            List<Float> temp = new ArrayList<Float>();
                            temp.add((float)arrays.get(0)[k]);
                            temp.add((float)arrays.get(0)[j]);
                            z[k][j] = ;
                        }
                    }
                    ((Plot3DPanel)this.plotPanel).addGridPlot(title, XYZMatrix);
                     * 
                     */
                }
            }
            //this.graphPanel.revalidate();
            //this.graphPanel.repaint();
            jProgressBar1.setMinimum(0);
            jProgressBar1.setMaximum((Integer)jSpinner7.getValue());
            this.trainButton.setEnabled(false);
            new AproximationTrainerThread(dataset,this.plotPanel,this.supervisedNetwork,(Integer)jSpinner7.getValue(),(Float)null,
                    jProgressBar1,errorPlot,false,this.trainButton,this.infoTextArea).start();
        }
    }catch(Exception e){JOptionPane.showMessageDialog(this, "Error");}
    }//GEN-LAST:event_trainButtonActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        List<Float> values = this.getDataFromSpinners(jPanel18);
        String outputs = Utils.listToCSV(this.supervisedNetwork.processData(values));
        this.infoTextArea.append("--------Salida--------");
        this.infoTextArea.append(System.getProperty("line.separator"));
        this.infoTextArea.append("Red: ");
        this.infoTextArea.append(outputs);
        this.infoTextArea.append(System.getProperty("line.separator"));
        if (jRadioButton2.isSelected()) {
            this.infoTextArea.append("Funcion: ");
            this.infoTextArea.append(new Double(Utils.getValueFromFunction(jTextField2.getText(),Double.parseDouble(values.get(0).toString()))).toString());
            this.infoTextArea.append(System.getProperty("line.separator"));
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void addSpinners(Integer qty, JPanel panel) {
        panel.removeAll();
        for (int i = 0; i < qty; i++ ) {
            GridBagConstraints c = new GridBagConstraints();
            //c.fill = GridBagConstraints.HORIZONTAL;
            c.gridx =  i;
            c.gridy = 0;
            JSpinner spinner = new JSpinner();
            spinner.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1f), Float.valueOf(-9999999), Float.valueOf(9999999), Float.valueOf(0.01f)));
            //spinner.setSize(500, 30);
            panel.add(spinner, c);
            panel.revalidate();
            panel.repaint();
        }
    }
    private void classificationTrainButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_classificationTrainButtonActionPerformed
        // TODO add your handling code here:
         this.graphPanel1.removeAll();
        if (this.jComboBox3.getSelectedItem() != null) {
           
            jComboBox3.setEnabled(false);
            AbstractDataset dataset = TrainingDataManager.getInstance().getDataset(this.jComboBox3.getSelectedItem().toString());
            PlotPanel pl = null;
            if (dataset instanceof SupervisedDataset) {
                switch (((SupervisedDataset)dataset).getDataRow(0).get(0).size()) {
                    case 2:
                        Plot2DPanel plot = new Plot2DPanel();
                        double[] x = new double[dataset.size()];
                        double[] y = new double[dataset.size()];
                        int i = 0;
                        for (List<List<Float>> row : ((SupervisedDataset)dataset).getData()) {
                            x[i] = row.get(0).get(0);
                            y[i] = row.get(0).get(1);
                            i++;
                        }
                        plot.addScatterPlot("Entradas", Color.BLUE, x, y);
                        this.graphPanel1.add(plot,BorderLayout.CENTER);
                        pl = plot;
                        break;
                    case 3:
                        Plot3DPanel plot3d = new Plot3DPanel();
                        double[] x1 = new double[dataset.size()];
                        double[] y1 = new double[dataset.size()];
                        double[] z = new double[dataset.size()];
                        int j = 0;
                        for (List<List<Float>> row : ((SupervisedDataset)dataset).getData()) {
                            x1[j] = row.get(0).get(0);
                            y1[j] = row.get(0).get(1);
                            z[j] = row.get(0).get(2);
                            j++;
                        }
                        plot3d.addScatterPlot("Entradas", Color.BLUE, x1, y1,z);
                        this.graphPanel1.add(plot3d,BorderLayout.CENTER);
                        pl = plot3d;
                        break;
                }
            }else{
                switch (((UnsupervisedDataset)dataset).getDataRow(0).size()) {
                    case 2:
                        
                        Plot2DPanel plot = new Plot2DPanel();
                        /*
                        double[] x = new double[dataset.size()];
                        double[] y = new double[dataset.size()];
                        int i = 0;
                        for (List<Float> row : ((UnsupervisedDataset)dataset).getData()) {
                            x[i] = row.get(0);
                            y[i] = row.get(1);
                            i++;
                        }
                        //plot.addScatterPlot("Entradas", Color.BLUE, x, y);
                         *
                         */
                        this.graphPanel1.add(plot,BorderLayout.CENTER);
                        pl = plot;
                        break;
                    case 3:
                        
                        Plot3DPanel plot3d = new Plot3DPanel();
                        /*
                        double[] x1 = new double[dataset.size()];
                        double[] y1 = new double[dataset.size()];
                        double[] z = new double[dataset.size()];
                        int j = 0;
                        for (List<Float> row : ((UnsupervisedDataset)dataset).getData()) {
                            x1[j] = row.get(0);
                            y1[j] = row.get(1);
                            z[j] = row.get(2);
                            j++;
                        }
                        plot3d.addScatterPlot("Entradas", Color.BLUE, x1, y1,z);
                         *
                         */
                        this.graphPanel1.add(plot3d,BorderLayout.CENTER);
                        pl = plot3d;
                        break;
                }
            }
            this.jProgressBar2.setMinimum(0);
            this.jProgressBar2.setMaximum((Integer)jSpinner9.getValue());
            this.classificationTrainButton.setEnabled(false);
            new ClassificationTrainerThread(dataset,pl,(this.supervisedNetwork == null)?this.unsupervisedNetwork:this.supervisedNetwork,
                    (Integer)jSpinner9.getValue(),null,jProgressBar2,colors,jTextArea1,this.classificationTrainButton).start();

        }
        
    }//GEN-LAST:event_classificationTrainButtonActionPerformed

    private List<Float> getDataFromSpinners(JPanel panel) {
        int componentCount = panel.getComponentCount();
        List<Float> data = new ArrayList<Float>();
        for (int i = 0; i < componentCount; i++) {
            Component component = panel.getComponent(i);
            if (component instanceof JSpinner) {
                data.add((Float)((JSpinner)component).getValue());
            }
        }
        return data;
    }

    private void drawSubPanels(JPanel panel, List<Float> data) {
        panel.removeAll();
        if (!(panel.getLayout() instanceof GridBagLayout)) {
            panel.setLayout(new GridBagLayout());
        }
        GridBagConstraints c = new GridBagConstraints();
        c.gridx = 0;
        c.gridy = 0;

        for (int i = 0; i < data.size(); i++) {
            if (i%4 != 0) {
                c.gridx++;
            } else {
                c.gridx = 0;
                c.gridy++;
            }
            JPanel subPanel = new JPanel();
            subPanel.setBounds(0, 0, 100, 100);
            subPanel.setBackground(Color.decode((data.get(i) != 0)?"0x9999DD":"0xFFFFFF"));
            subPanel.setLayout(new BorderLayout());
            subPanel.add(new JLabel(data.get(i).toString()),BorderLayout.CENTER);
            panel.add(subPanel,c);
        }
        panel.revalidate();
        panel.repaint();
    }

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        this.jComboBox3.setModel(TrainingDataManager.getInstance().getComboModel((this.supervisedNetwork == null)?false:true));
        if (this.jComboBox3.getModel().getSize() > 0)
            this.jComboBox3.setSelectedIndex(0);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox3ActionPerformed
        // TODO add your handling code here:
        int size = TrainingDataManager.getInstance().getDataset(this.jComboBox3.getSelectedItem().toString()).getInputSize();
        this.addSpinners(size,this.jPanel14);
    }//GEN-LAST:event_jComboBox3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        List<Float> results = null;
        List<Float> inputs = VectorUtils.normalize(this.getDataFromSpinners(jPanel14));
        if (this.supervisedNetwork != null) {
            results = this.supervisedNetwork.processData(inputs);
        }else{
            results = this.unsupervisedNetwork.processData(inputs);
        }
        jTextArea1.append("**** Resultado ****");
        jTextArea1.append(System.getProperty("line.separator"));
        jTextArea1.append(results.toString());
        jTextArea1.append(System.getProperty("line.separator"));
        //this.drawSubPanels(jPanel7, results);
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        jTextArea1.setText("");
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton3ActionPerformed
        // TODO add your handling code here:
        jTextField4.setEnabled(true);
        jTextField5.setEnabled(true);
        jComboBox4.setEnabled(false);
        jButton6.setEnabled(false);
    }//GEN-LAST:event_jRadioButton3ActionPerformed

    private SupervisedDataset transformDataSet(UnsupervisedDataset dataset, int windowSize) {
        SupervisedDataset newDataset = new SupervisedDataset();
        List<Float> aux = null;
        List<List<Float>> aux2 = null;
        if (dataset.size() > windowSize + 1){
            for(int i = windowSize ; i < dataset.size(); i++) {
                aux = new ArrayList<Float>(windowSize);
                aux2 = new ArrayList<List<Float>>(2);
                for(int j = i-windowSize; j < i; j++) {
                    aux.add(dataset.getDataRow(j).get(0));
                }
                aux2.add(aux);
                aux2.add(dataset.getDataRow(i));
                newDataset.addDataRow(aux2);
            }
        }
        return newDataset;
    }
    private void trainButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trainButton1ActionPerformed
        // TODO add your handling code here:
        SupervisedDataset dataset = this.transformDataSet((UnsupervisedDataset)TrainingDataManager.getInstance().
                getDataset((String)jComboBox4.getSelectedItem()), (Integer)jSpinner12.getValue());
        this.graphPanel2.removeAll();
        this.errorPlotPanel1.removeAll();
        Plot2DPanel errorPlot = new Plot2DPanel();
        this.errorPlotPanel1.add(errorPlot,BorderLayout.CENTER);
        Plot2DPanel plot = new Plot2DPanel();
        this.graphPanel2.add(plot,BorderLayout.CENTER);
        List<double[]> arrays = null;
        double[] x = null;
        double[] y = null;

        if (this.supervisedNetwork != null) {
            if (jTextField2.isEnabled()) {
                
            }

            jProgressBar3.setIndeterminate(true);
            //new AproximationTrainerThread(dataset.getData(),plot,this.supervisedNetwork,(Integer)jSpinner11.getValue(),0f,jProgressBar3,errorPlot,true).start();
        }

    }//GEN-LAST:event_trainButton1ActionPerformed

    private void jRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton4ActionPerformed
        // TODO add your handling code here:
         jTextField4.setEnabled(false);
        jTextField5.setEnabled(false);
        jComboBox4.setEnabled(true);
        jButton6.setEnabled(true);
    }//GEN-LAST:event_jRadioButton4ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        this.jComboBox4.setModel(TrainingDataManager.getInstance().getComboModel(false));
        if (this.jComboBox4.getModel().getSize() > 0)
            this.jComboBox4.setSelectedIndex(0);
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        // TODO add your handling code here:
        int size = TrainingDataManager.getInstance().getDataset(this.jComboBox2.getSelectedItem().toString()).getInputSize();
        this.addSpinners(size,this.jPanel18);
    }//GEN-LAST:event_jComboBox2ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        JFileChooser jc = new JFileChooser();
        jc.setFileFilter(new NeuralFileFilter());
        int c = jc.showOpenDialog(this);
        if (c == JFileChooser.APPROVE_OPTION) {
            AbstractNeuralNetwork n = Utils.xmlToNetwork(jc.getSelectedFile());
            if (n instanceof Perceptron) {
                this.supervisedNetwork = (Perceptron)n;
                jSpinner1.setValue(((Perceptron)n).getNeurons().getSize());
                jLabel5.setText("Hardlimit");
                //jSpinner6.setValue(((Perceptron)n).get);
                this.unsupervisedNetwork = null;
                jComboBox1.setSelectedIndex(1);
                //CardLayout cl = (CardLayout) jPanel4.getLayout();
                //cl.show(this.jPanel4, "card2");
            }
            if (n instanceof Adaline) {
                this.supervisedNetwork = (Adaline)n;
                this.unsupervisedNetwork = null;
                jLabel5.setText("lineal");
                jSpinner1.setValue(((Adaline)n).getNeurons().getSize());
                jComboBox1.setSelectedIndex(2);
                //CardLayout cl = (CardLayout) jPanel4.getLayout();
                //cl.show(this.jPanel4, "card2");
            }
            if (n instanceof MultiLayerPerceptron) {
                this.supervisedNetwork = (MultiLayerPerceptron)n;
                this.unsupervisedNetwork = null;
                jSpinner2.setValue((((MultiLayerPerceptron)n).getNeurons().size()));
                jSpinner3.setValue((((MultiLayerPerceptron)n).getLearningRate()));
                List<SimpleLayer> l = ((MultiLayerPerceptron)n).getNeurons();
                this.jPanel5.removeAll();
                for(int i = 0; i < l.size(); i++){
                    Integer[] data = new Integer[2];
                    data[0] = l.get(i).getNeuron(0).getTransferFunctionObject() instanceof LogSigmoidFunction?0:l.get(i).getNeuron(0).getTransferFunctionObject() instanceof TanhFunction?2:1;
                    data[1] = l.get(i).getSize();
                    this.addComponents(true, data);
                }
                jComboBox1.setSelectedIndex(3);
                //CardLayout cl = (CardLayout) jPanel4.getLayout();
                //cl.show(this.jPanel4, "card3");
            }
            if (n instanceof CompetitiveNetwork) {
                this.supervisedNetwork = null;
                this.unsupervisedNetwork = (CompetitiveNetwork)n;
                jSpinner4.setValue(((CompetitiveNetwork)n).getNeurons().get(0).getSize());
                jSpinner5.setValue(((CompetitiveNetwork)n).getLearningRate());
                jComboBox1.setSelectedIndex(4);
                //CardLayout cl = (CardLayout) jPanel4.getLayout();
                //cl.show(this.jPanel4, "card4");
            }
            this.createNet(true);
        }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        JFileChooser jc = new JFileChooser();
        jc.setFileFilter(new NeuralFileFilter());
        int c = jc.showSaveDialog(this);
        if (c == JFileChooser.APPROVE_OPTION) {
            Utils.networkToXml(supervisedNetwork!=null?supervisedNetwork:unsupervisedNetwork, jc.getSelectedFile().getPath());
        }

    }//GEN-LAST:event_jMenuItem2ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton classificationTrainButton;
    private javax.swing.JPanel competitivePanel;
    private javax.swing.JButton createNetButton;
    private javax.swing.JPanel errorPlotPanel;
    private javax.swing.JPanel errorPlotPanel1;
    private javax.swing.JPanel graphPanel;
    private javax.swing.JPanel graphPanel1;
    private javax.swing.JPanel graphPanel2;
    private javax.swing.JTextArea infoTextArea;
    private javax.swing.JTextArea infoTextArea1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JProgressBar jProgressBar2;
    private javax.swing.JProgressBar jProgressBar3;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButton jRadioButton3;
    private javax.swing.JRadioButton jRadioButton4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JSpinner jSpinner1;
    private javax.swing.JSpinner jSpinner10;
    private javax.swing.JSpinner jSpinner11;
    private javax.swing.JSpinner jSpinner12;
    private javax.swing.JSpinner jSpinner2;
    private javax.swing.JSpinner jSpinner3;
    private javax.swing.JSpinner jSpinner4;
    private javax.swing.JSpinner jSpinner5;
    private javax.swing.JSpinner jSpinner6;
    private javax.swing.JSpinner jSpinner7;
    private javax.swing.JSpinner jSpinner8;
    private javax.swing.JSpinner jSpinner9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JPanel mlpPanel;
    private javax.swing.JPanel perceptronPanel;
    private javax.swing.JButton trainButton;
    private javax.swing.JButton trainButton1;
    // End of variables declaration//GEN-END:variables


}
